package com.database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.database.DataCon;

public class DataDel {
	
	
	public DataDel(){}
	
	String sqlstr;
    Connection con=null;
	Statement stmt2=null;
	ResultSet rs=null;
	DataCon dt = new DataCon();
	
	public void DataDel(String name) throws SQLException{
		con = dt.DbConn();
		stmt2 = con.createStatement();  
		sqlstr = "select * from filecontrol where fileName = '"+ name +"'";
		System.out.println(sqlstr);
		rs = stmt2.executeQuery(sqlstr);
		while(rs.next()){
			String fileName = rs.getString("fileName");
			System.out.println(rs.getString("fileName"));
			sqlstr = "Insert into del_filecontrol(del_fileName) values('"+fileName+"')";
			stmt2.executeUpdate(sqlstr);
			System.out.println(name);
			sqlstr =  "delete from filecontrol where fileName = '"+ name +"'";
			System.out.println(sqlstr);
			stmt2.executeUpdate(sqlstr);
		}
	}

}
